/// <summary>
/// Copyright 2010 Ivo Limmen (ivo@limmen.org)
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
/// 
/// http://www.apache.org/licenses/LICENSE-2.0
/// 
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
/// </summary>

using System;
using System.Collections.Generic;
using Services.Configuration.Model.Meta;

namespace Services.Configuration.Model
{
	public class Section
	{
		private List<Key> keys = new List<Key>();

		private Documentation documentation = null;
		
		private string name;
		
		private string host;
		
		public Section (string name)
			: this(name, null)
		{				
		}
		
		public Section (string name, string host)
		{
			this.name = name;
			this.host = host;
		}

		public void SetDocumentation(Documentation documentation) 
		{
			this.documentation = documentation;
		}
		
		public Documentation GetDocumentation() 
		{
			return this.documentation;
		}
		
		public void AddKey(Key key) 
		{
			this.keys.Add(key);
		}
		
		public string GetName() 
		{
			return this.name;
		}
		
		public string GetHost() 
		{
			return this.host;
		}

		public Key GetKeyByName(string name)
		{
			foreach (Key key in this.keys) 
			{
				if (key.GetName().Equals(name, StringComparison.InvariantCultureIgnoreCase)) 
				{
					return key;
				}
			}
			
			return null;
		}
	}
}
